 <template>
  <div class="put-Table-div">
    <el-table
      v-loading="loading"
      :data="
        tableData.slice((currentPage - 1) * pagesize, currentPage * pagesize)
      "
      style="width: 100%"
    >
      <el-table-column prop="name" label="姓名" width="140"> </el-table-column>
      <el-table-column prop="phone" label="手机号码" width="200">
      </el-table-column>

      <el-table-column prop="times" label="购次" width="130"> </el-table-column>
      <el-table-column prop="points" label="积分" width="130">
      </el-table-column>
      <el-table-column prop="card" label="客户身份" width="180">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="mini"
            plain
            @click="duanxin(scope.$index, scope.row)"
            >发短信</el-button
          >
          <el-button
            type="primary"
            size="mini"
            plain
            @click="Addtips(scope.$index, scope.row)"
            >加标签</el-button
          >
          <el-button
            type="primary"
            size="mini"
            plain
            @click="handleEdit(scope.$index, scope.row)"
            >加积分</el-button
          >
          <el-button
            size="mini"
            type="danger"
            icon="el-icon-delete"
            @click="handleDelete(scope.$index, scope.row)"
            circle
          ></el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="paginDiv">
      <el-pagination
        small
        @size-change="size_change"
        @current-change="current_change"
        :current-page="currentPage"
        :page-size="pagesize"
        layout="prev, pager, next"
        :total="tableData.length"
      >
      </el-pagination>
    </div>
  </div>
</template>
  <style lang='scss' scoped>
.paginDiv {
  margin-left: 500px;
}
</style>
  <script>
import { putcontro } from "../http/httpUser";
import { delecus } from "../http/httpUser";
export default {
  props: { tableDa: Array },
  data() {
    return {
      tableData: [],
      total: 0,
      pagesize: 4,
      currentPage: 1,
      loading: true,
    };
  },
  created() {},
  watch: {
    tableDa(val) {
      this.tableData = val;
    },
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      delecus(row.phone)
        .then((res) => {
          if (res.data.code == 200) {
            this.tableData = this.tableData.splice(index, 1);
            this.$message.success("删除成功!");
          } else {
            this.$message.error("删除失败!");
          }
        })
        .catch();
    },
    duanxin(index, row) {
      putcontro("促销短信", row.phone)
        .then((res) => {
          if (res.data.code == 1) {
            this.$message.success("发送成功!");
          } else {
            this.$message.error("发送失败");
          }
        })
        .catch();
    },
    Addtips(index, row) {
      console.log(index, row);
    },
    size_change(newSize) {
      this.pagesize = newSize;
    },
    current_change(newPage) {
      this.currentPage = newPage;
    },
  },

  mounted() {},
  computed: {},
};
</script>



  <style lang='scss' >
@import "../assets/scss/baseColor";

.el-table thead {
  color: #909399;
  font-weight: 500;
  background: $back-color !important;
}
</style>